const jwt = require('jsonwebtoken')

// 生成
exports.generateToken = function (pyload, secretKey, expiresIn) {
    return jwt.sign(pyload, secretKey, { expiresIn })
}

// 验证
exports.verifyToken = function (token, secretKey) {
    try {
        const claim = jwt.verify(token, secretKey)
        return claim
    } catch (error) {
        return null
    }
}

